package com.shsxt.crm.controller.report;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shsxt.crm.service.IReportService;
import com.shsxt.framework.context.BaseController;

/**
 * 统计报表
 * 
 * @author Mr.YongGan.Zhang
 *
 */
@Controller
@RequestMapping("/report")
public class ReportController extends BaseController {

	@Autowired
	private IReportService reportService;

	@GetMapping("/{type}")
	public String index(@PathVariable("type") int type) {
		switch (type) {
		case 0:
			return "customer_contribution";
		case 1:
			return "customer_gc";
		case 2:
			return "customer_serve";
		default:
			return "500";
		}
	}

	/**
	 * 查询 客户贡献值金额
	 * 
	 * @param name
	 * @param pageNum
	 * @param rows
	 * @return
	 */
	@PostMapping("/queryCustomersContribution")
	@ResponseBody
	public Map<String, Object> queryCustomersContribution(@RequestParam(value = "name", defaultValue = "") String name,
			@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
			@RequestParam(value = "rows", defaultValue = "10") Integer rows) {
		return reportService.queryCustomersContribution(name, pageNum, rows);
	}

	@GetMapping("/queryCustomersGc")
	@ResponseBody
	@CrossOrigin("*")
	public Map<String, Object> queryCustomersGc() {
		return reportService.queryCustomersGc();
	}

	/**
	 * 查询 客户 服务
	 * 
	 * @return
	 */
	@GetMapping("/queryCustomersServerAnalysis")
	@ResponseBody
	@CrossOrigin("*")
	public Map<String, Object> queryCustomersServerAnalysis() {
		return reportService.queryCustomersServerAnalysis();
	}

}
